#include <stdio.h>
#include <string.h>
#include "network.h"

void* star_run(void* arg)
{
	Network* nw = (Network*)arg;
	char buf[1024];
	for(;;)
	{
		nrecv(nw,buf,sizeof(buf));
		printf("server recv:%s\n",buf);
		sprintf(buf,"server back:%s",buf);
		nsend(nw,buf,strlen(buf)+1);
		}
	}




int main()
{
	Network* nw = open_network('s',SOCK_STREAM,"",6699);
	if(NULL == nw)
	{
		printf("open_network return null!\n");
		return -1;
		}
	for(;;)
	{
		Network* clinw = accept_network(nw);
		if(NULL == clinw) continue;
		pthread_t pid;
		pthread_creat(&pid,NULL,star_run,clinw);
		}
	}
